package com.smedi.ismedi.notification.core.port.adapter.persistence.repository.impl;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smedi.ismedi.notification.core.domain.aggregatemodel.MailLog;
import com.smedi.ismedi.notification.core.domain.repository.MailLogRepository;
import com.smedi.ismedi.notification.core.port.adapter.persistence.model.MailLogEntity;
import com.smedi.ismedi.notification.core.port.adapter.persistence.mybatis.mapper.MailLogMapper;
import com.smedi.ismedi.web.starter.util.DozerUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

/**
 * @className: MailLogRepositoryImp
 * @Description: TODO
 * @version: v1.0.0
 * @author: wzx
 * @date: 2022/11/23 15:41
 */

@Slf4j
@Repository
@AllArgsConstructor
public class MailLogRepositoryImpl extends ServiceImpl<MailLogMapper, MailLogEntity> implements MailLogRepository, IService<MailLogEntity> {

    private final DozerUtil dozerUtil;

    @Override
    public MailLog doInsert(MailLog mailLog) {
        MailLogEntity mailLogEntity = dozerUtil.convertor(mailLog, MailLogEntity.class);
        this.getBaseMapper().insert(mailLogEntity);
        return dozerUtil.convertor(mailLogEntity, MailLog.class);
    }
}